Skip to content

document the NDC convention for the initial matrix - #206

Merged
igagis merged 5 commits into
cppfw:mainfrom
igagis-bot:top-left-origin
Nov 30, 2026
Merged

igagis merged 5 commits into
cppfw:mainfrom
igagis-bot:top-left-origin

Conversation

@igagis-bot

Copy link
Copy Markdown
Contributor

Document the framework convention for the initial matrix in the context's API docs:

  • NDC (normalized device coordinates) spans x, y, z from [0, 1]
  • x-axis right, y-axis down, z-axis away from the viewer
  • x = 0 maps to the left viewport edge, x = 1 to the right viewport edge
  • y = 0 maps to the top viewport edge, y = 1 to the bottom viewport edge
  • z = 0 maps to the near clipping plane, z = 1 to the far clipping plane

This is the single canonical convention that all renderers (OpenGL, OpenGL ES, DirectX, Vulkan) target.

The window coordinate system used by the renderers (to_window_coords,
get/set_viewport, get/set_scissor) is always top-left origin (x right,
y down). Document this in the context's API docs so the renderers have
a single canonical convention to implement.
The framework convention for the initial matrix: NDC (normalized device
coordinates) spans x, y, z from [0, 1] with x-axis right, y-axis down and
z-axis away from the viewer. With the initial_matrix: x = 0 maps to the
left viewport edge, x = 1 to the right viewport edge; y = 0 maps to the
top viewport edge, y = 1 to the bottom viewport edge; z = 0 maps to the
near clipping plane, z = 1 to the far clipping plane.
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 28.21%. Comparing base (f7304df) to head (43d399c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
- Coverage   28.55%   28.21%   -0.35%     
==========================================
  Files         239      239              
  Lines        8945     9443     +498     
  Branches     2785     2883      +98     
==========================================
+ Hits         2554     2664     +110     
- Misses       6057     6416     +359     
- Partials      334      363      +29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

The framework convention maps framework z=0 to the near clipping plane
and z=1 to the far plane (z away), and the frustum (r4) now maps near
to NDC z=0 and far to NDC z=1. The previous z flip in the widget chain
(scale(1, -1, -1)) made framework z=0 map to NDC z=+1, which is the far
plane — clipping out-of-range z values.

The y flip remains (framework y=0 is top, OpenGL viewport is y-up).
@igagis
igagis merged commit 0a5aabe into cppfw:main Nov 30, 2026
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants